#import <UIKit/UIKit.h>
#import "FSServer.h"
#import "BLEDevice.h"

typedef NS_ENUM (uint16_t, FSDeviceType) {
	FSDeviceTypeUnknown			= 15,
	
	FSDeviceTypeTreadmill		= 0,		//跑步机
	FSDeviceTypeElliptical		,			//椭圆机
	FSDeviceTypeBicycle			,			//健身车
};

//设备广播数据结构
typedef struct {
	uint16_t		model;
	uint16_t		factory : 12;
	FSDeviceType	type : 4;
	
	uint32_t		serial;
	
	//Byte			mode;
	//Byte			state;
	//Byte			error;
} FSDeviceDataStruct;

#pragma mark -
//运动秀蓝牙设备
@interface FSDevice : NSObject

+ (NSArray <FSDevice *> *)devices;		//获取当前用户使用过的设备（按使用次数排序）

+ (void)refresh;

+ (BOOL)checkFormat:(NSData *)data;

- (instancetype)initWithParam:(NSDictionary *)param;
- (void)updateWithData:(NSData *)data;

@property (nonatomic, assign)	NSInteger		tag;

@property (nonatomic, readonly) FSDeviceType	type;			//机型类型
@property (nonatomic, readonly) uint			model;			//机型代码
@property (nonatomic, readonly) uint			serial;			//机型序列号

@property (nonatomic, readonly) NSString		*name;			//设备名称
@property (nonatomic, readonly) NSString		*url;			//设备官方网址
@property (nonatomic, readonly) NSString		*factory;		//设备制造商
@property (nonatomic, readonly) NSString		*summary;		//设备简介

@property (nonatomic, readonly) NSDictionary	*params;

- (id)imageWithDefault:(UIImage *)image result:(void (^)(UIImage *image, BOOL isDefault))result;

@end
